"use strict";
const cardparse = require('./build/Release/cardparse');

var rf = require("fs");
var teststr = rf.readFileSync("card.txt", "utf-8");

//var dir="D:/work/slave/third-party/cardParse/conf"
//加载dir文件夹下的配置文件
//var obj = cardparse(dir);

//可以使用new方式创建，等价
//var obj = new cardparse();
//默认加载当前文件夹下的配置文件，加载完成之后不可以重复加载，加载失败时可以再次加载
var obj = cardparse();

//obj.getInitFlag() 获取cardparse初始化标志，1表示成功 负数初始化失败，可能是配置文件未读取
var initflag = obj.getInitFlag()
if (initflag < 1) {
    console.log("Init Faild the initflag=" + initflag);
    return
}
/* 
 * 1：只识别身份证号码
 * 2：只识别银行卡号
 * 3：两者都识别
 * return json-map object
 *  numBank: int32, 银行卡号码个数
 *  numIdCard: int32, 身份证号码个数
 *  numTotal: int32, 总的号码个数
 *  strBank: string, 银行卡号码字符串，用空格分割
 *  strIdCard: string, 身份证号码字符串，用空格分割
 */
var re = obj.cardParse(teststr, 1)
console.log(re);
re = obj.cardParse(teststr, 2)
console.log(re);
re = obj.cardParse(teststr, 3)
console.log(re);

/*下面是示例输出结果
{ numBank: 0,
  numIdCard: 48,
  numTotal: 48,
  strBank: '',
  strIdCard: '52263519890117727X 522635198101135012 522635197408242598 522635197306216575 522635198504252512 45102519760724935X 451025198108207096 451025198608159537 45102519750311213X 45102519890
5264798 532628197407285391 532628198705183398 411525197306176273 411525197805213614 411525198207268214 411525197604165310 411525198309256599 411525198001199954 411525198106127818 41152519860925587
0 610324197905181938 610324198003197337 610324198802205073 61032419700926695X 511702197409284963 51170219870626850X 511702197506159005 511702199002187781 511702198307271621 522635198501118828 5226
35197008278006 522635198403166623 522635197205163101 532628198701109924 532628198207178107 532628198206219261 532628197105229941 532628198002194680 532628198206109644 532628197903253743 5326281972
0718326X 532628198605112402 532628198109243980 12000019890820784X 120000198804217007 120000197802221665 120000198703246503 120000197005233321 ' }
{ numBank: 3,
  numIdCard: 0,
  numTotal: 3,
  strBank: '6228480402564890018 6222021001116245702 6228481698729890079 ',
  strIdCard: '' }
{ numBank: 3,
  numIdCard: 48,
  numTotal: 51,
  strBank: '6228480402564890018 6222021001116245702 6228481698729890079 ',
  strIdCard: '52263519890117727X 522635198101135012 522635197408242598 522635197306216575 522635198504252512 45102519760724935X 451025198108207096 451025198608159537 45102519750311213X 45102519890
5264798 532628197407285391 532628198705183398 411525197306176273 411525197805213614 411525198207268214 411525197604165310 411525198309256599 411525198001199954 411525198106127818 41152519860925587
0 610324197905181938 610324198003197337 610324198802205073 61032419700926695X 511702197409284963 51170219870626850X 511702197506159005 511702199002187781 511702198307271621 522635198501118828 5226
35197008278006 522635198403166623 522635197205163101 532628198701109924 532628198207178107 532628198206219261 532628197105229941 532628198002194680 532628198206109644 532628197903253743 5326281972
0718326X 532628198605112402 532628198109243980 12000019890820784X 120000198804217007 120000197802221665 120000198703246503 120000197005233321 ' }*/